<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    div {
      width: 100px;
      height: 100px;
      padding: 10px;
      border: 1px solid black;
      margin: 20px;
    }
  </style>
</head>

<body>
  <div></div>

  <script>
    const elem = document.querySelector('div')

    // clientWidth/clientHeight = width/height + padding
    console.log('elem.clientWidth', elem.clientWidth)
    console.log('elem.clientHeight', elem.clientHeight)

    // clientTop/clientLeft 边框宽度
    console.log('elem.clientTop', elem.clientTop)
    console.log('elem.clientLeft', elem.clientLeft)
  </script>
</body>

</html>